package com.hzhc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzhc.entity.VersionContent;
import com.hzhc.mapper.VersionContentMapper;
import com.hzhc.service.VersionContentService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.vo.VersionContentVo;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 日志详情 服务实现类
 * </p>
 *
 * @author 功不唐捐
 * @since 2024-04-07
 */
@Service
public class VersionContentServiceImpl extends ServiceImpl<VersionContentMapper, VersionContent> implements VersionContentService {
    @Override
    public List<VersionContentVo> getVersionContentPage(Page<VersionContentVo> page, VersionContentVo vo) {
        IPage<VersionContentVo> iPage = baseMapper.getVersionContentPage(page, vo);
        return iPage.getRecords();
    }

    @Override
    public ResultUtil<T> addVersionContent(VersionContent vo) {
        vo.setDisable(false).setCreateTime(LocalDateTime.now());
        boolean b = save(vo);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }

    @Override
    public ResultUtil<T> updateVersionContent(VersionContent vo) {
        vo.setDisable(false);
        boolean b = updateById(vo);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }

    @Override
    public ResultUtil<T> deleteVersionContent(long id) {
        VersionContent vo=new VersionContent().setId(id).setDisable(true);
        boolean b = updateById(vo);
        return b ? ResultUtil.ok() : ResultUtil.fail();
    }
}
